package com.yupi.oj.controller;

import com.yupi.oj.common.BaseResponse;
import com.yupi.oj.common.ResultUtils;
import com.yupi.oj.judge.model.dto.JudgeRequest;
import com.yupi.oj.judge.service.JudgeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yanghaifeng
 * @date 2024/4/11 15:39
 */
@RequestMapping("/judge")
@RestController
@Api(tags = "判题接口")
public class JudgeController {

    @Autowired
    private JudgeService service;

    @ApiOperation("判题")
    @PostMapping("/question")
    public BaseResponse<Long> judgeQuestion(@RequestBody JudgeRequest judgeRequest, HttpServletRequest request) {
        service.judge(judgeRequest, request);
        return ResultUtils.success(null);
    }
}
